#include <gflags/gflags.h>
#include <vector>

#include "log.h"
#include "mysql_session.h"

void append_signal(chat::ChatSessionMemberTable& session_table) {
    chat::ChatSessionMember session1("session_id-1", "user_id-1");
    chat::ChatSessionMember session2("session_id-1", "user_id-2");
    session_table.append(session1);
    session_table.append(session2);
}

void append_multi(chat::ChatSessionMemberTable& session_table) {
    chat::ChatSessionMember session1("session_id-2", "user_id-1");
    chat::ChatSessionMember session2("session_id-2", "user_id-2");
    chat::ChatSessionMember session3("session_id-2", "user_id-3");
    std::vector<chat::ChatSessionMember> vec({session1, session2, session3});
    session_table.append(vec);
}

void remove_singal(chat::ChatSessionMemberTable& session_table) {
    chat::ChatSessionMember session2("session_id-2", "user_id-2");
    session_table.remove(session2);
}

void remove_session(chat::ChatSessionMemberTable& session_table) {
    session_table.remove("session_id-2");
}

void get_session_members(chat::ChatSessionMemberTable& session_table) {
    auto ret = session_table.members("session_id-1");
    for (auto member : ret) {
        LOG_DEBUG("user_id: {}", member);
    }
}

int main(int argc, char* argv[]) {
    chat::initLogger(1, false, " ");

    std::shared_ptr<odb::mysql::database> db = chat::DataBaseFactory::create(
        1, "root", "123", "chat", "127.0.0.1", 0, "utf8");

    chat::ChatSessionMemberTable session_table(db);

    get_session_members(session_table);

    return 0;
}